sw uno: do not throw exceptions on getString()
getString() is passive method and no reason to throw
an exception instead of returning empty string in some
corner situations like object is being disposed.
As a compromise information about inbalid state is
reported into log.
Change-Id: Ied6ecb356ce341d44e5a2bb21fb8379257e38c31
Reviewed-on: https://gerrit.libreoffice.org/64442
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Tested-by: Jenkins
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index c80adc0..cd87c86 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1347,7 +1347,9 @@
}
else
{
throw uno::RuntimeException();
// Seems object is being disposed or some other problem occurs.
// Anyway from user point of view object still exist, so on that level this is not an error
SAL_WARN("sw.uno", "getString() for invalid paragraph called. Returning empty string.");
}
return aRet;
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 0657f7b..e73c74e 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -906,9 +906,8 @@
const uno::Reference< text::XTextCursor > xRet = CreateCursor();
if(!xRet.is())
{
uno::RuntimeException aRuntime;
aRuntime.Message = cInvalidObject;
throw aRuntime;
SAL_WARN("sw.uno", "cursor was not created in getString() call. Returning empty string.");
return OUString();
}
xRet->gotoEnd(true);
return xRet->getString();
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 204f8ed..c1fe908 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1392,7 +1392,10 @@
if(m_pView)
{
if (!IsTextSelection( false ))
throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
{
SAL_WARN("sw.uno", "no text selection in getString() " << static_cast<cppu::OWeakObject*>(this));
return uRet;
}
ShellMode eSelMode = m_pView->GetShellMode();
switch(eSelMode)